package com.ffs.fsm.thread;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 执行队列
 * @author ffs80 created 2021/7/9
 */
public class QueueExecutor extends ThreadPoolExecutor {

    private String name;

    /**
     * 核心线程数
     */
    private int corePoolSize;
    /**
     * 最大线程数
     */
    private int maxPoolSize;


    public QueueExecutor(String name,int corePoolSize, int maxPoolSize) {
        super(corePoolSize, maxPoolSize, 30L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),new PoolThreadFactory(name));
        this.name = name;
        this.corePoolSize = corePoolSize;
        this.maxPoolSize = maxPoolSize;
    }

    public String getName() {
        return name;
    }

    @Override
    public int getCorePoolSize() {
        return corePoolSize;
    }

    public int getMaxPoolSize() {
        return maxPoolSize;
    }
}
